package com.superteam.zzl.activity;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;

import java.util.Timer;
import java.util.TimerTask;

public class WelcomeActivity extends AppCompatActivity {

    private Timer timer;
    private SharedPreferences sharedPreferences;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_welcome);
        timer = new Timer();
        nextPage();
    }

    /**
     * 共享参数判断是否第一次启动App   定时跳转
     */
    private void nextPage(){
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                sharedPreferences = getSharedPreferences("count", Context.MODE_PRIVATE);
                int count = sharedPreferences.getInt("count",0);
                if(count == 0){
                    startActivity(new Intent(WelcomeActivity.this,FirstWelcomeActivity.class));
                }else{
                    startActivity(new Intent(WelcomeActivity.this,MainActivity.class));
                }
                finish();
                SharedPreferences.Editor editor = sharedPreferences.edit();
                editor.putInt("count",++count);
                editor.commit();

            }
        },3000);
    }



}
